@extends('layouts.admin_master')
@section('content')
    <div class="card">
        <div class="card-header">
            <ul class="nav">
                <li class="nav-item">
                    <a href="{{route('attr.attr.index')}}" class="nav-link active">属性列表</a>
                </li>
                <li class="nav-item">
                    <a href="{{route('attr.attr.create')}}" class="nav-link">添加属性</a>
                </li>
            </ul>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-sm-12">
                    <table class="table table-striped table-bordered zero-configuration dataTable"
                           id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
                        <thead>
                        <tr role="row">
                            <th>id</th>
                            <th>属性名称</th>
                            <th>父级属性</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($attrs as $attr)
                            <tr role="row" class="odd">
                                <td>{{$attr['id']}}</td>
                                <td>{{$attr['attr_name']}}</td>
                                <td>{{$attr->attr?$attr->attr->attr_name:'顶级属性'}}</td>
                                <td>
                                    <a class="btn btn-success btn-sm" href="{{route('attr.attr.edit',$attr)}}">编辑</a>
                                    <a class="btn btn-danger btn-sm"  onclick="del(this)" href="javascript:;">删除</a>
                                    <form action="{{route('attr.attr.destroy',$attr)}}" method="post">
                                        @method('DELETE') @csrf
                                    </form>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="card-footer text-muted">
            {{$attrs->links()}}
        </div>
    </div>
@endsection
@push('js')
    @include('layouts.del')
@endpush
